﻿using System;
using System.Security;
using System.Runtime.InteropServices;
using ToolSharp.Windows.Native.Libraries;

namespace ToolSharp.Windows.Native.SafeHandles
{
	[SecurityCritical]
	public sealed class SafeLocalAllocHandle : SafeBuffer
	{
		// Methods
		public SafeLocalAllocHandle()
			: base(true)
		{
		}

		public SafeLocalAllocHandle(IntPtr handle)
			: base(true)
		{
			base.SetHandle(handle);
		}

		[SecurityCritical]
		protected override bool ReleaseHandle()
		{
			return (Kernel.LocalFree(base.handle) == IntPtr.Zero);
		}

		public static SafeLocalAllocHandle InvalidHandle
		{
			get
			{
				return new SafeLocalAllocHandle(IntPtr.Zero);
			}
		}
	}

 

}
